package com.chuangjiangx.member.manager.web.web.score.request;

import com.chuangjiangx.commons.request.PageRequest;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
public class ScoreGiftCountByTimeDetailRequest extends PageRequest {

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;

    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    /**
     * 终端类型
     */
    private Byte terminalType;

    /**
     * 会员名称或手机号
     */
    private String nameOrMobile;

    /**
     * 兑换id
     */
    private Long scoreGiftId;

    public void setNameOrMobile(String nameOrMobile) {
        if (nameOrMobile != null) {
            this.nameOrMobile = "%" + nameOrMobile + "%";
        }
    }

    public void setEndTime(Date endTime) {
        if (endTime != null) {
            endTime.setTime(endTime.getTime() + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
        }
        this.endTime = endTime;
    }
}
